package wz

import (
	"crypto/md5"
	"encoding/hex"
	"github.com/go-resty/resty/v2"
)

type HttpClient struct {
	cli      *resty.Client
	Id       string
	GuestId  string
	Secret   string
	Host     string
	DemoHost string
}

var Hc *HttpClient

func InitHttpClient(id, guestId, secret, host, demoHost string) {
	if Hc != nil {
		return
	}
	Hc = &HttpClient{
		cli:      resty.New(),
		Id:       id,
		GuestId:  guestId,
		Secret:   secret,
		Host:     host,
		DemoHost: demoHost,
	}
}

func md5v(str string) string {
	h := md5.New()
	h.Write([]byte(str))
	return hex.EncodeToString(h.Sum(nil))
}
